package com.zeta.demo.es.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.zetaframework.base.entity.SuperEntity;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 文章表
 *
 * @author gcc
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@TableName("demo_post")
public class Post extends SuperEntity<Long> {

    @Serial
    private static final long serialVersionUID = 1L;

    /** 文章标题 */
    @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "文章标题不能为空")
    @Size(max = 60, message = "文章标题长度不能超过60")
    @TableField(value = "title")
    private String title;

    /** 文章内容 */
    @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "文章内容不能为空")
    @TableField(value = "content")
    private String content;

    /** 作者名 */
    @Schema(description = "作者名", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "作者名不能为空")
    @TableField(value = "author")
    private String author;

    /** 发布时间 */
    @Schema(description = "发布时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(value = "publish_time")
    private LocalDateTime publishTime;

    /** 浏览量 */
    @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(value = "view_count")
    private Integer viewCount;

    /** 标签列表 */
    @Schema(description = "标签列表", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(exist = false)
    private List<String> tags;

    /** 测试字段 */
    @Schema(description = "测试字段", hidden = true)
    @TableField(exist = false)
    private LocalDate testField;

}
